package ModelLayer;
import java.util.ArrayList;

public class LoanContainer
{
    private static LoanContainer loanContainer;
    private ArrayList<Loan> allLoans;
    
    /**
     * Singleton constructor
     */
    private LoanContainer()
    {
        allLoans = new ArrayList<Loan>();
    }
    
    /**
     * Returns the instance of this class.
     * Creates it if it does not exist
     */
    public static LoanContainer getInstanse()
    {
        if(loanContainer == null)
        {
            loanContainer = new LoanContainer();
        }
        
        return loanContainer; 
    }
    
    /**
     * Returns all loans
     */
    public ArrayList<Loan> getAllLoans()
    {
        return allLoans;
    }
    
    /**
     * Creates a new loan
     */
    public void newLoan(Person person, Example example, String date, String period)
    {
        Loan loan = new Loan(person, example, date, period);
        allLoans.add(loan);
    }
}